package com.sunl.mall.ali.mq.api.consumer;

import com.aliyun.openservices.ons.api.order.OrderAction;
import com.sunl.mall.ali.mq.model.RocketMqMessageBody;
import com.sunl.mall.ali.mq.model.RocketMqMessageContext;
import com.sunl.mall.ali.mq.serializer.RocketMqDeserializer;
import com.sunl.mall.common.api.topic.MqTopic;

/**
 * 顺序消息监听
 * <p>
 * 继承该接口实现监听指定的topic
 *
 * @param <T>
 */
public interface RocketMqOrderMessageListener<T> extends RocketMqDeserializer<T> {

    /**
     * 处理消息
     *
     * @param body    反序列化后的消息体
     * @param context 消息上下文
     * @return Action 接收到消息后执行的操作
     * @throws Exception exception
     */
    OrderAction call(RocketMqMessageBody<T> body, RocketMqMessageContext context) throws Exception;

    /**
     * 订阅主题
     *
     * @return com.sunl.mall.common.api.topic not null
     */
    MqTopic subscribe();
}
